You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
540 B
16 lines
540 B
import { delCache } from "#server/utils/context";
|
|
import { deleteCategory, getCategoryById } from "../../service/category";
|
|
|
|
export default defineWrappedResponseHandler(async (event) => {
|
|
const id = getRouterParam(event, "id");
|
|
if (!id) return R.throwError(400, "缺少分类 ID", null);
|
|
|
|
const existing = await getCategoryById(id);
|
|
if (!existing) return R.throwError(404, "分类不存在", null);
|
|
|
|
await deleteCategory(id);
|
|
await delCache(`category:${id}`);
|
|
await delCache("categories:tree");
|
|
|
|
return R.success(null);
|
|
});
|
|
|